package com.future.mayi.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.future.mayi.R;
import com.future.mayi.model.PerformanceModel;
import com.future.mayi.utils.PriceUtils;
import com.future.mayi.view.xrecyclerview.XRecyclerView;

import butterknife.BindView;
import butterknife.ButterKnife;


public class PerformanceAdapter extends BaseRecyclerViewAdapter<PerformanceModel> {


    public PerformanceAdapter(Context context, XRecyclerView recyclerView) {
        super(context, null, recyclerView);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(getView(parent, R.layout.layout_performance_item));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        PerformanceModel model = getItem(position);
        ViewHolder holder = (ViewHolder) viewHolder;
        setText(holder.tvAllPrice, PriceUtils.getPriceText2(model.getTotal_quotas()));
        setText(holder.tvPrice1, "+" + PriceUtils.getPriceText2(model.getMy_quotas()));
        setText(holder.tvPrice2, "+" + PriceUtils.getPriceText2(model.getSub_quotas()));
        setText(holder.tvTitle, model.getDate());
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_all_price)
        TextView tvAllPrice;
        @BindView(R.id.tv_price_1)
        TextView tvPrice1;
        @BindView(R.id.tv_price_2)
        TextView tvPrice2;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
